/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.plant;

import java.awt.Image;
import model.game.GameInterface;
import model.item.Item;
import model.map.cell.PlantableCell;

/**
 * A specialization of DefaultPlant that can be used as a base instead of Plant
 *
 * Provides some additional default characteristics of Plants
 *
 * Plants once harvested removed from game.
 */
public abstract class SingleHarvestPlant extends DefaultPlant {

  /**
   * Constructor
   */
  public SingleHarvestPlant(GameInterface game, PlantableCell cell) {
    super(game, cell);
  }

  /**
   * Return true iff this plant is ready to be harvested
   */
  public boolean isHarvestable() {
    return !is_seed_ &&
            happiness_ >= timeToHarvest();
  }

  @Override
  public Item harvest() {
    assert isHarvestable();
    Item harvest_result =
            game_.getItemManager().constructItemFromName(getFruitName());
    game_.getCreatures().getPlants().removePlant(this);
    return harvest_result;
  }

  /**
   * Retrieves the fruit name from this plant when harvested
   */
  protected abstract String getFruitName();

  /**
   * Retrieves the days required to go from seed to mature
   */
  @Override
  protected abstract int timeToMature();

  /**
   * Retrieves the days before this plant dies
   */
  @Override
  protected abstract int timeToDie();

  /**
   * Retrieves the days before this plant can be harvested from mature state,
   * having beeing harvested harvest_count times before
   */
  protected abstract int timeToHarvest();

  /**
   * Retrieves the HP of this plant at the given level
   * level can be accessed through getLevel()
   */
  @Override
  protected abstract int getHPAtCurrentLevel();

  /**
   * Returns true iff plant can be upgraded again now
   * It's current level is given in getLevel()
   */
  @Override
  public abstract boolean canUpgrade();

  /**
   * Retrieves the price to upgrade this plant's level
   * It's current level is given in getLevel()
   * @requires canUpgrade()
   */
  @Override
  public abstract int getUpgradeCost();

   /**
   * Returns the image sprite of this plant
   */
  @Override
  public abstract Image getImage();

  /**
   * Returns the name of this plant
   * Primary Key
   */
  @Override
  public abstract String getName();

  /**
   * Return the season only during this season this plant may grow
   */
  @Override
  public abstract String getSeason();

  /**
   * Returns the description of this plant
   */
  @Override
  public abstract String getDescription();
}

